#include <mega1284p.h>
#include <mega128_twi.h>
#include <gpdr_init.h>
#include <gpdr_files.h>
#include <viniSPI.h>
#include <twi.h>
#include <rtc.h>
//#include <gps.h>
//#include <nmea.h>

void lithium_recharge(unsigned char mode);
void comparator_stopwatch0(unsigned char channel); // in a2d_isr
void comparator_stopwatch1(unsigned char channel); // in a2d_isr
void clock(void);
char gps_getchar_timed(unsigned int *timeout_100us);
char gps_getchar();
void gps_putchar(char c);
void gps_putstr(char *str);
void gps_putstrf(char flash *str);
char sim_getchar();
void sim_putchar(char c);
void sim_putstr(char *str);
void sim_putstrf(char flash *str);
//char twi_getchar_timed(unsigned int *timeout_ms);
//char twi_getchar(void);
//void twi_putchar(char c, char twi_rdf, char twi_con, char twi_stat);

#define OSC_FREQ 15360000
#define USART_FUNDAMENTAL 960000 // OSC_FREQ/16

#define GPS_END_OF_FIELD 44 // Convert comma to LF
#define BUFFER_END_OF_FIELD 10 // and LF to NULL

#define RTC_W 0xD0
#define RTC_R 0xD1

#define ADC_VREF_AVCC 0x60
#define ADC_VREF_INTL 0xE0
#define LAST_ADC_INPUT 7
#define ADC_03P0D1 7
#define ADC_03P3D1 6
#define ADC_05P0D5 5
#define ADC_28P0D9 4

//#define ADC_28P0D9 1
//#define ADC_05P0D5 2
//#define ADC_03P3D1 3
//#define ADC_03P0D1 5
